#!/usr/bin/env python3
# -*- coding:utf-8 -*-
import configparser
import os

from config.conf import cm




class ReadConfig(object):
    """配置文件"""

    def __init__(self):
        self.config = configparser.RawConfigParser()  # 当有%的符号时请使用Raw读取
        self.config.read(cm.ini_file, encoding='utf-8')

    def _get(self, section, option):
        """获取config.ini中的配置"""
        return self.config.get(section, option)

    def _set(self, section, option, value):
        """更新config.ini中的配置"""
        self.config.set(section, option, value)
        with open(cm.ini_file, 'w') as f:
            self.config.write(f)

    def url(self):
        """获取测试域名"""
        env = os.environ [ "env" ]
        return self._get("HOST", env)+self._get("HOST","url")



ini = ReadConfig()

if __name__ == '__main__':
    print(ini.url())
